package com.lx.t11_20;

/**
 * @author c先生
 * @date 2022年04月26日 下午 9:06:25
 * @describe
 */

import java.util.*;
public class Main20 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            String password = sc.nextLine();
            char[] chars = password.toCharArray();
            boolean flag = true;
            int a = 0 , b = 0 , c = 0 , d = 0;
            if (password.length() <= 8) {
                flag = false;
            }
            for (char c1 : chars) {
                if (c1 >= '0' && c1 <= '9') {
                    a = 1;
                } else if (c1 >= 'a' && c1 <= 'z') {
                    b = 1;
                } else if (c1 >= 'A' && c1 <= 'Z') {
                    c = 1;
                } else {
                    d = 1;
                }
            }
            for (int i = 3; i < password.length(); i++) {
                if (password.substring(i).contains(password.substring(i - 3, i))) {
                    flag = false;
                }
            }


            if ((a+b+c+d) < 3) {
                flag = false;
            }
            if (flag) {
                System.out.println("OK");
            } else {
                System.out.println("NG");
            }
        }
    }
}